package com.caocaog.market.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.caocaog.market.entity.dto.PushStatisticDTO;
import com.getui.push.v2.sdk.dto.res.statistic.StatisticDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.Date;
import java.util.Map;

/**
 * 推送结果
 *
 * @author chechen
 * @date 2022-05-25
 */
@Data
@NoArgsConstructor
@TableName("mk_push_result")
@Accessors(chain = true)
@ApiModel(value = "mk_push_result对象", description = "推送结果")
public class PushResult implements Serializable {
    private static final long serialVersionUID = 1L;

    @TableId(type = IdType.AUTO)
    @ApiModelProperty("ID")
    private Integer id;

    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "创建时间", hidden = true)
    private Date createTime;

    @ApiModelProperty(value = "日期")
    private String date;

    @ApiModelProperty(value = "总共的消息统计")
    private PushStatisticDTO total;

    @ApiModelProperty(value = "个推的消息统计")
    private PushStatisticDTO gt;

    @ApiModelProperty(value = "oppo的消息统计")
    private PushStatisticDTO op;

    @ApiModelProperty(value = "小米的消息统计")
    private PushStatisticDTO xm;

    @ApiModelProperty(value = "华为的消息统计")
    private PushStatisticDTO hw;

    @ApiModelProperty(value = "vivo的消息统计")
    private PushStatisticDTO vv;

    public PushResult(Map<String, StatisticDTO> statisticDTOMap) {
        this.total = PushStatisticDTO.convertFor(statisticDTOMap.getOrDefault("total", null));
        this.gt = PushStatisticDTO.convertFor(statisticDTOMap.getOrDefault("gt", null));
        this.op = PushStatisticDTO.convertFor(statisticDTOMap.getOrDefault("op", null));
        this.xm = PushStatisticDTO.convertFor(statisticDTOMap.getOrDefault("xm", null));
        this.hw = PushStatisticDTO.convertFor(statisticDTOMap.getOrDefault("hw", null));
        this.vv = PushStatisticDTO.convertFor(statisticDTOMap.getOrDefault("vv", null));
    }



}
